<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <!--bootstrap插件-->
    <meta name="viewport" content="width=device-width, initial-scale=1.0"/>
    <link href="/static/plugin/bootstrap/bootstrap-3.3.7-dist/css/bootstrap.min.css" rel="stylesheet"/>
    <link href="/static/plugin/jo/joUI.css" rel="stylesheet"/>
    <!--字体插件-->
    <link href="/static/plugin/font-awesome-4.7.0/css/font-awesome.min.css" rel="stylesheet"/>
    <link href="/static/plugin/layui-2.4.3/css/layui.css" rel="stylesheet"/>
    <!--ztree-->
    <link href="/static/plugin/zTree/css/metroStyle/metroStyle.css" rel="stylesheet"/>
    <!--common-->
    <link href="/static/css/common.css" rel="stylesheet"/>
    <title>农用地信息表视图</title>
</head>
<body class="skin-default">

<div class="container-fluid">
    <div class="row">
        <div class="col-xs-12">
            <!--视图块-->
            <div class="container-fluid card">
                <div class="row">
                    <div class="col-xs-12 col-sm-12 col-md-12 col-lg-12">
                        <!--检索栏-->
                        <form class="form-inline search-bar" id="pageForm">
                            <div class="form-group">
                                <label class="control-label">编号：&nbsp;</label>
                                <input type="text" name="organizationcode" class="form-control">
                            </div>
                            <div class="form-group">
                                <label class="control-label">地块名称：&nbsp;</label>
                                <input type="text" name="landname" class="form-control">
                            </div>
                            <div class="form-group">
                                <label class="control-label">类别名称：&nbsp;</label>
                                <input type="text" name="typename" class="form-control">
                            </div>
                            <div class="form-group">
                                <label class="control-label">所属区域：&nbsp;</label>
                                <input type="text" name="subordinatearea" class="form-control">
                            </div>
                            <div class="form-group">
                                <label class="control-label">耕地类型：&nbsp;</label>
                                <input type="text" name="cultivatedland" class="form-control">
                            </div>
                            <button type="button" class="btn btn-primary" onclick="joView.select()"><i
                                    class="fa fa-search" aria-hidden="true"></i>&nbsp;查询
                            </button>
                            <button type="button" class="btn btn-primary" onclick="reset()"><i
                                    class="fa fa-search" aria-hidden="true"></i>&nbsp;重置
                            </button>
                        </form>
                        <!--/检索栏-->
                    </div>
                </div>
                <div class="row">
                    <div class="col-xs-12 col-sm-12 col-md-12 col-lg-12">
                        <!--按钮栏-->
                        <div class="form-group button-bar" id="buttonhtml">
                            <!--<button isShow="" type="button" class="btn btn-primary" onclick="joView.add()">
                                <i class="fa fa-plus" aria-hidden="true"></i>&nbsp;新增
                            </button>
                            <button type="button" class="btn btn-danger" onclick="joView.del()">
                                <i class="fa fa-trash-o" aria-hidden="true"></i>&nbsp;删除
                            </button>
                            <button type="button" class="btn btn-warning" onclick="window.location.reload()">
                                <i class="fa fa-refresh" aria-hidden="true"></i>&nbsp;刷新
                            </button>
                            <button type="button" class="btn btn-success" onclick="exportConfig()">
                                <i class="fa fa-download" aria-hidden="true"></i>&nbsp;导出
                            </button>-->
                            <!--<button type="button" class="btn btn-warning" onclick="joView.lock()">-->
                            <!--<i class="fa fa-lock" aria-hidden="true"></i>&nbsp;锁定-->
                            <!--</button>-->
                            <!--<button type="button" class="btn btn-warning" onclick="joView.unlock()">-->
                            <!--<i class="fa fa-unlock" aria-hidden="true"></i>&nbsp;解锁-->
                            <!--</button>-->
                        </div>
                        <!--/按钮栏-->
                    </div>
                </div>
                <div class="row">
                    <div class="col-xs-12 col-sm-12 col-md-12 col-lg-12">
                        <div class="table-bar">
                            <!--grid-->
                            <div class="table-responsive">
                                <table class="table table-bordered table-hover" id="mainList"
                                       dataUrl="/nyd/uviAgriculturallandinformation/getPage"
                                       deleteUrl="/nyd/uviAgriculturallandinformation/delete"
                                       lockUrl="/nyd/uviAgriculturallandinformation/lock"
                                       unlockUrl="/nyd/uviAgriculturallandinformation/unlock"
                                       formUrl="/page/nyd/uviAgriculturallandinformationForm.html">
                                    <col field="organizationcode" title="编号" width="15%" align="" event="click"/>
                                    <col field="landname" title="地块名称" width="15%" align=""/>
                                    <col field="regions" title="行政区划" width="15%" align=""/>
                                    <col field="subordinatearea" title="所属区域" width="15%" align=""/>
                                    <col field="typename" title="类别名称" width="15%" align=""/>
                                    <col field="longitude" title="经度" width="15%" align=""/>
                                    <col field="dimension" title="纬度" width="15%" align=""/>
                                    <col field="cultivatedland" title="耕地类型" width="15%" align=""/>
                                    <col field="ownership" title="权属" width="8%" align=""/>
                                    <col field="unlack" title="锁定" width="7%" align=""/>
                                    <col field="_opt" title="操作" width="15%" align=""/>
                                    <col field="_opt1" title="查看" width="10.2%" align="" event="click"/>
                                </table>
                            </div>
                            <!--/grid-->

                            <!--分页条-->
                            <div class="page-bar" gridId="mainList">

                            </div>
                            <!--/分页条-->
                        </div>
                    </div>
                </div>
            </div>

        </div>
    </div>
</div>

<!--弹窗元素-->
<script id="cultivateChangeBox" type="template">
    <form id="cultivateChangeForm" class="padding-15" style="width: 100%;height: 300px;">
        <div class="row">
            <div class="young-form-item col-md-12 must">
                <div class="young-form-label">变更前类别名称</div>
                <div class="young-form-tips"></div>
                <div class="young-form-input-block">
                    <input type="text" name="typenamebefore" id="typenamebefore" readonly value="" class="form-control "
                           ErrEmpty="变更前类别名称不允许为空"/>
                </div>
            </div>
            <div class="young-form-item col-md-12 must">
                <div class="young-form-label">变更后类别名称</div>
                <div class="young-form-tips"></div>
                <div class="young-form-input-block">
                    <select name="typenameafter" value="" class="form-control" ErrEmpty="变更后类别名称不允许为空">
                        <option value="1">优先保护类耕地</option>
                        <option value="2">安全利用类耕地</option>
                        <option value="3">严格管控类耕地</option>
                    </select>
                </div>
            </div>
            <div class="young-form-item col-md-12 must">
                <div class="young-form-label">变更人</div>
                <div class="young-form-tips"></div>
                <div class="young-form-input-block">
                    <input type="text" name="changepeople" value="" class="form-control " ErrEmpty="变更人不允许为空"/>
                </div>
            </div>
            <div class="young-form-item col-md-12 must">
                <div class="young-form-label">变更原因</div>
                <div class="young-form-tips"></div>
                <div class="young-form-input-block">
                    <textarea name="causeofchange" class="form-control " rows="3" ErrEmpty="变更原因不允许为空"></textarea>
                </div>
            </div>
        </div>
    </form>
</script>


<!--配置信息-->
<script src="/static/js/config.js"></script>
<!--jquery-->
<script src="/static/plugin/jquery/jquery-3.3.1.js"></script>
<script src="/static/plugin/jquery/jquery.cookie.js"></script>
<!--bootstrap-->
<script src="/static/plugin/bootstrap/bootstrap-3.3.7-dist/js/bootstrap.min.js"></script>
<!--[if lt IE 9]>
<script src="/static/plugin/other/html5shiv.js"></script>
<script src="/static/plugin/other/respond.min.js"></script>
<![endif]-->
<!--layui-->
<script src="/static/plugin/layui-2.4.3/layui.all.js"></script>
<!--ztree-->
<script src="/static/plugin/zTree/js/jquery.ztree.all.js"></script>
<!--common-->
<script src="/static/js/common.js"></script>
<!--jo-->
<script src="/static/plugin/jo/jo.js"></script>
<script src="/static/plugin/jo/jo-adapt.js"></script>
<script src="/static/plugin/jo/jo-page-view.js"></script>
<script src="/static/plugin/jo/jo-page-form.js"></script>
<script src="/static/plugin/jo/jo-listener.js"></script>
<script type="text/javascript">
    $(function () {
        var buttonhtml = "";
        if (jo.getUrlParam('tilltype') == undefined || jo.getUrlParam('tilltype') == '') {
            buttonhtml = '<span class="young-button-placeholder" navigateId="NAV_TYPE_HTML_BUTTON"></span>\n' +
                '                            <span class="young-button-placeholder" navigateId="LAND_VIEW_FORM"></span>' + '<span class="young-button-placeholder" navigateId="LAND_LOCK_BUTTON"></span>';
        } else {
            buttonhtml = '<span class="young-button-placeholder" navigateId="YXBH_LAND_VIEW_BUTTON"></span>\n' +
                '                            <span class="young-button-placeholder" navigateId="NAV_TYPE_HTML_BUTTON"></span>' + '<span class="young-button-placeholder" navigateId="LAND_LOCK_BUTTON"></span>'
            ;
        }

        $('#buttonhtml').html(buttonhtml);
        joView.init({
            grid: $("#mainList"),
            PKName: "id",
            condition: {tilltype: jo.getUrlParam('tilltype')},
            transferParam: 'tilltype=' + jo.getUrlParam('tilltype'),

        });//初始化页面

        initButton();
    });


    //变更类型:获得当前数据行的id
    /*change = function (id,tilltype,landname ,sUrl, sWidth, sHeight, sTitle) {
        if (jo.isValid(joView.params["formUrl"])) {
            var idStr = "";
            if (!jo.isValid(id)) {//没有传入ID,获取选中复选框的ID
                idStr = jo.getCheckBoxValue(joView.params["PKName"]);
            } else {//有传入值
                idStr = id;
            }
            if (idStr == "") {
                jo.showMsg("请选择一项待变更选项");
            } else {
                top.jo.showWin("/page/nyd/uviCultivatechangeForm.html", "1600px", "800px", "变更类型", "变更类型", false, true);
            }
        }
    }*/

    //表格渲染时行处理,参数1为当前行的数据对象,参数2为当前行的索引值(最小为0)
    joView.handleItem = function (oItem, iIndex) {
        oItem.unlack = formatUnlack(oItem.unlack);
        oItem._opt = '<button type="button" class="btn btn-sm btn-outline btn-primary" onclick="cultivateChange(\'' + oItem.id + '\',\'' + oItem.tilltype + '\')"> <i class="fa fa-magic" aria-hidden="true"></i>&nbsp;耕地类型变更</button>'
        oItem._opt1 = '<button type="button" class="btn btn-sm btn-outline btn-primary" >&nbsp;详细信息</button>'
        //alert(oItem.regions);
    };

    //格式化锁定状态
    function formatUnlack(unlack) {
        if (unlack == 0) {
            return '<span class="label label-primary">未锁定</span>';
        } else {
            return '<span class="label label-danger">锁定</span>';
        }
    }

    //跳转
    /*function cultivateChange(id) {
        if (id) {
            top.jo.showWin("/page/nyd/uviCultivatechangeForm.html?organizationcode=" + id, "1600px", "800px", "耕地类型变更", "耕地类型变更", false, true);
        }
    }*/
    //类型变更
    function cultivateChange(id, tilltype) {
        if (!id) {
            return;
        }
        jo.showDialog($('#cultivateChangeBox').html(), 'cultivateChangeWin', true, {
            title: '耕地类型变更', btn: ['确认变更', '取消'], area: ['580px', '400px'], btn1: function (idx) {
                if (jo.checkForm($('#cultivateChangeForm'))) {//表单验证
                    var data = jo.form2Json('cultivateChangeForm');
                    data.organizationcode = id;
                    jo.postAjax('/nyd/uviCultivatechange/cultivateChange', data, function (json) {
                        if (json && json.code == 0) {
                            jo.showMsg('变更成功', {icon: 1});
                        } else {
                            jo.showMsg('变更失败', {icon: 2});
                        }
                        joView.reloadCurrentPage();//刷新数据
                        jo.reset('cultivateChangeForm');//重置表单
                        jo.close(idx);//关闭
                    });
                }
            }, success: function () {
                if (tilltype != null) {
                    if (tilltype == 1) {
                        var lx = "优先保护类耕地";
                    } else if (tilltype == 2) {
                        var lx = "安全利用类耕地";
                    } else {
                        var lx = "严格管控类耕地";
                    }
                }


                $('#typenamebefore').val(lx);
            }
        });
    }

    //表格渲染完成后的回调,参数为表格数据(数组对象)
    joView.setGridDataAfter = function (oList) {
    };

    //导出
    function exportConfig() {
        var ids = jo.getCheckBoxValue("id");
        if (!ids) {
            jo.confirm("确定要导出全部吗？", function (index) {
                jo.post("/nyd/uviAgriculturallandinformation/export", {ids: ids});
                layer.close(index);
            });
        } else {
            jo.confirm("确定要导出选中的数据吗？", function (index) {
                jo.post("/nyd/uviAgriculturallandinformation/export", {ids: ids});
                layer.close(index);
            });
        }
    }

    /* 关于joView更多回调函数和配置参数可查看jo-page-view.js */
</script>
</body>
</html>
